@inherits RadzenComponentWithChildren

@if (Visible)
{
    <ul @ref=@Element style=@Style @attributes=@Attributes class=@GetCssClass() id=@GetId()>
        @if (Responsive)
        {
        <li class="rz-menu-toggle-item">
            <button class="rz-menu-toggle" @onclick=@OnToggle>
                @if (IsOpen)
                {
                    <i class="rzi">close</i>
                } else
                {

                    <i class="rzi">menu</i>
                }
            </button>
        </li>
        }
        <CascadingValue Value=this>
            @ChildContent
        </CascadingValue>
    </ul>
}
@code {
    [Parameter]
    public bool Responsive { get; set; } = true;

    private bool IsOpen { get; set; } = false;

    protected override string GetComponentCssClass()
    {
        var classList = new List<string>();

        classList.Add("rz-menu");

        if (Responsive)
        {
            if (IsOpen)
            {
                classList.Add("rz-menu-open");
            }
            else
            {
                classList.Add("rz-menu-closed");
            }
        }

        return string.Join(" ", classList);
    }

    void OnToggle()
    {
        IsOpen = !IsOpen;
    } 

    [Parameter]
    public EventCallback<MenuItemEventArgs> Click { get; set; }
}